<?php
namespace ManagerX\Controller;
use Think\Controller;
class ConfigController extends Controller {
    public function index(){
        if(session('?user') && session('user.role') == 1){
            $results = M('config')->select();
            $configs = array_reduce($results, function($carry, $item) {
                $carry[$item['name']] = $item['value'];
                return $carry;
            }, []);  
            
            $this->assign('config', $configs);
            $this->display('index');
        }else{
            $this->error('未登录或无权限。', 'User/login', 3);
        }
    }
}